package com.jg.controller;

import com.jg.dto.BookParam;
import com.jg.entity.Book;
import com.jg.service.BookService;
import org.apache.ibatis.annotations.Result;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 86130
 * @version 1.0
 * @description: 图书控制器
 * @date 2025/6/16 下午2:47
 */
@RestController
@RequestMapping("/book")
@CrossOrigin
public class BookController {
    @Autowired
    BookService bookService;

    //获取书籍列表
    @RequestMapping("/list")
    public List<Book> list(@RequestBody BookParam bookParam) {
        return bookService.list(bookParam);
    }

    //添加书籍
    @RequestMapping("/add")
    public String add(@RequestBody Book book) {
        return bookService.add(book);
    }

    //通过id获取书籍详情
    @RequestMapping("/detail")
    public Book detail(Integer bookID) {
        return bookService.detail(bookID);
    }

    //修改书籍
    @RequestMapping("/update")
    public String update(@RequestBody Book book) {
        return bookService.update(book);
    }

    //删除书籍
    @RequestMapping("/delete")
    public String delete(Integer bookID) {
        return bookService.delete(bookID);
    }
}
